<template>
    <div>
      <BHeader :back="true">添加</BHeader>
      <ul>
        <li>
          <label for="bookName">名字</label>
          <input type="text" v-model="book.bookName" id="bookName">
        </li>
        <li>
          <label for="bookInfo">信息</label>
          <input type="text" v-model="book.bookInfo" id="bookInfo">
        </li>
        <li>
          <label for="bookCover">图片</label>
          <input type="text" v-model="book.bookCover" id="bookCover">
        </li>
        <li>
          <label for="bookPrice">价格</label>
          <input type="text" v-model.number="book.bookPrice" id="bookPrice">
        </li>
        <button @click="addData">增加</button>
      </ul>
    </div>
</template>

<script>
  import BHeader from '../base/BHeader.vue';
  import {addBook} from '../api';
    export default {
        data() {
            return {
                book: {}
            }
        },
      components:{
        BHeader
      },
      methods:{
        async addData(){
          await addBook(this.book);
          this.$router.push("/list")
        }
      }
    }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">
  ul{
    margin:50px 10px 0 10px;
    li{
      label{
        display: block;
        font-size: 25px;
      }
      input{
        height: 25px;
        width: 100%;
        margin: 10px 0;
      }
    }
  }
  button{
    display: block;
    width: 60px;
    height: 25px;
    background: lightskyblue;
    color: #FFF;
    border: none;
    border-radius: 5px;
    outline: none;
    color: #2a2a2a;
    line-height: 25px;
  }
</style>
